<?php
namespace RMD\AccountBundle\Entity;

use Doctrine\ORM\EntityRepository;

class ListsRepository extends EntityRepository
{
    public function countSubscribers($listid)
    {
		$connection = $this->getEntityManager()->getConnection();
		return $connection->fetchColumn('select count(*) from subscribers where lists_id = ?', array((int)$listid), 0);
        /*return $this->getEntityManager()
            ->createQuery('SELECT COUNT(*) FROM RMDAccountBundle:Subscriber s WHERE s.lists_id = ?1')
			->setParameter(1, (int)$listid)
            ->getResult();*/
    }
	public function _countSubscribers($groupId)
    {
		$connection = $this->getEntityManager()->getConnection();
		/*$stmt = $connection->prepare('select count(*) as count from subscribers_groups where group_id = ?');
		$stmt->bindValue(1, (int)$groupId, \PDO::PARAM_INT);
		$stmt->execute();*/
        /*$this->getEntityManager()
            ->createQuery('SELECT COUNT(*) FROM RMDAccountBundle:Group g WHERE g.lists_id=')
            ->getResult();*/
		//select count(*) as count from subscribers_groups where group_id = 16
		return $connection->fetchColumn('select count(*) from subscribers_groups where group_id = ?', array((int)$groupId), 0);
    }
}
